<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
	</head>
	<body>
	</body>
</html>
<script type="text/javascript">
	//promise可用于封装异步操作 
	// 实例化promise对象
	const p = new Promise(function(resolve,reject){
		setTimeout(function(){
			// let data = 'data';
			// resolve(data);
			let err = '数据读取失败';
			reject(err);
		},2000)
	});
	// 调用promise对象的then方法
	p.then(function(value){
		console.log(value)
	}, function(reason){
		console.error(reason)
	})
</script>